package com.richstonedt.smartcity.xaytsccommoncs.config;

import com.obs.services.ObsConfiguration;
import com.richstonedt.smartcity.xaytsccommoncs.util.ObsUtil;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * <b><code>ObsConfig</code></b>
 * <p/>
 * Description  自动注入obsService上传工具类
 * <p/>
 * <b>Creation Time:</b> 2022/3/29 15:56:45
 *
 * @author tangjiahuan
 * @since xaytsc-common-be
 */
@Configuration
@EnableConfigurationProperties(ObsProperties.class)
public class ObsConfig {

    private final ObsProperties obsProperties;

    public ObsConfig(ObsProperties obsProperties) {
        this.obsProperties = obsProperties;
    }

    @Bean
    public ObsUtil obsService(){
        ObsConfiguration config = new ObsConfiguration();
        config.setSocketTimeout(40000);
        config.setConnectionTimeout(40000);
        config.setEndPoint(obsProperties.getEndPoint());
        return new ObsUtil(obsProperties.getBucketName(), obsProperties.getBucketLoc(), config);
    }

}
